home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Frame;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import java.util.Vector;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.swing.filechooser.FileFilter;
- import javax.swing.filechooser.FileSystemView;
- import javax.swing.filechooser.FileView;
- import javax.swing.plaf.FileChooserUI;
-
- public class JFileChooser extends JComponent implements Accessible {
- private static final String uiClassID = "FileChooserUI";
- public static final int OPEN_DIALOG = 0;
- public static final int SAVE_DIALOG = 1;
- public static final int CUSTOM_DIALOG = 2;
- public static final int CANCEL_OPTION = 1;
- public static final int APPROVE_OPTION = 0;
- public static final int ERROR_OPTION = -1;
- public static final int FILES_ONLY = 0;
- public static final int DIRECTORIES_ONLY = 1;
- public static final int FILES_AND_DIRECTORIES = 2;
- public static final String CANCEL_SELECTION = "CancelSelection";
- public static final String APPROVE_SELECTION = "ApproveSelection";
- public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY = "ApproveButtonTextChangedProperty";
- public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY = "ApproveButtonToolTipTextChangedProperty";
- public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY = "ApproveButtonMnemonicChangedProperty";
- public static final String DIRECTORY_CHANGED_PROPERTY = "directoryChanged";
- public static final String SELECTED_FILE_CHANGED_PROPERTY = "SelectedFileChangedProperty";
- public static final String SELECTED_FILES_CHANGED_PROPERTY = "SelectedFilesChangedProperty";
- public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY = "fileFilterChanged";
- public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY = "FileSystemViewChanged";
- public static final String FILE_VIEW_CHANGED_PROPERTY = "fileViewChanged";
- public static final String FILE_HIDING_CHANGED_PROPERTY = "FileHidingChanged";
- public static final String FILE_FILTER_CHANGED_PROPERTY = "fileFilterChanged";
- public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY = "fileSelectionChanged";
- public static final String ACCESSORY_CHANGED_PROPERTY = "AccessoryChangedProperty";
- private static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY = "AcceptAllFileFilterUsedChanged";
- public static final String DIALOG_TITLE_CHANGED_PROPERTY = "DialogTitleChangedProperty";
- public static final String DIALOG_TYPE_CHANGED_PROPERTY = "DialogTypeChangedProperty";
- public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY = "ChoosableFileFilterChangedProperty";
- private String dialogTitle;
- private String approveButtonText;
- private String approveButtonToolTipText;
- private int approveButtonMnemonic;
- private ActionListener actionListener;
- private Vector filters;
- private JDialog dialog;
- private int dialogType;
- private int returnValue;
- private JComponent accessory;
- private FileView fileView;
- private FileView uiFileView;
- private boolean useFileHiding;
- private int fileSelectionMode;
- private boolean multiSelectionEnabled;
- private boolean useAcceptAllFileFilter;
- private FileFilter fileFilter;
- private FileSystemView fileSystemView;
- private File currentDirectory;
- private File selectedFile;
- private File[] selectedFiles;
- protected AccessibleContext accessibleContext;
- // $FF: synthetic field
- static Class class$java$awt$Frame;
- // $FF: synthetic field
- static Class class$java$awt$event$ActionListener;
-
- public JFileChooser() {
- this((File)null, (FileSystemView)null);
- }
-
- public JFileChooser(File var1) {
- this((File)var1, (FileSystemView)null);
- }
-
- public JFileChooser(File var1, FileSystemView var2) {
- this.dialogTitle = null;
- this.approveButtonText = null;
- this.approveButtonToolTipText = null;
- this.approveButtonMnemonic = 0;
- this.actionListener = null;
- this.filters = new Vector(5);
- this.dialog = null;
- this.dialogType = 0;
- this.returnValue = -1;
- this.accessory = null;
- this.fileView = null;
- this.uiFileView = null;
- this.useFileHiding = true;
- this.fileSelectionMode = 0;
- this.multiSelectionEnabled = false;
- this.useAcceptAllFileFilter = true;
- this.fileFilter = null;
- this.fileSystemView = null;
- this.currentDirectory = null;
- this.selectedFile = null;
- this.accessibleContext = null;
- this.setup(var2);
- this.setCurrentDirectory(var1);
- }
-
- public JFileChooser(String var1) {
- this((String)var1, (FileSystemView)null);
- }
-
- public JFileChooser(String var1, FileSystemView var2) {
- this.dialogTitle = null;
- this.approveButtonText = null;
- this.approveButtonToolTipText = null;
- this.approveButtonMnemonic = 0;
- this.actionListener = null;
- this.filters = new Vector(5);
- this.dialog = null;
- this.dialogType = 0;
- this.returnValue = -1;
- this.accessory = null;
- this.fileView = null;
- this.uiFileView = null;
- this.useFileHiding = true;
- this.fileSelectionMode = 0;
- this.multiSelectionEnabled = false;
- this.useAcceptAllFileFilter = true;
- this.fileFilter = null;
- this.fileSystemView = null;
- this.currentDirectory = null;
- this.selectedFile = null;
- this.accessibleContext = null;
- this.setup(var2);
- if (var1 == null) {
- this.setCurrentDirectory((File)null);
- } else {
- this.setCurrentDirectory(this.fileSystemView.createFileObject(var1));
- }
-
- }
-
- public JFileChooser(FileSystemView var1) {
- this((File)null, var1);
- }
-
- public boolean accept(File var1) {
- boolean var2 = true;
- if (this.fileFilter != null) {
- var2 = this.fileFilter.accept(var1);
- }
-
- return var2;
- }
-
- public void addActionListener(ActionListener var1) {
- super.listenerList.add(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")), var1);
- }
-
- public void addChoosableFileFilter(FileFilter var1) {
- if (var1 != null && !this.filters.contains(var1)) {
- FileFilter[] var2 = this.getChoosableFileFilters();
- this.filters.addElement(var1);
- ((JComponent)this).firePropertyChange("ChoosableFileFilterChangedProperty", var2, this.getChoosableFileFilters());
- }
-
- this.setFileFilter(var1);
- }
-
- public void approveSelection() {
- this.returnValue = 0;
- if (this.dialog != null) {
- this.dialog.setVisible(false);
- }
-
- this.fireActionPerformed("ApproveSelection");
- }
-
- public void cancelSelection() {
- this.returnValue = 1;
- if (this.dialog != null) {
- this.dialog.setVisible(false);
- }
-
- this.fireActionPerformed("CancelSelection");
- }
-
- public void changeToParentDirectory() {
- File var1 = this.getCurrentDirectory();
- this.setCurrentDirectory(this.getFileSystemView().getParentDirectory(var1));
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- public void ensureFileIsVisible(File var1) {
- this.getUI().ensureFileIsVisible(this, var1);
- }
-
- protected void fireActionPerformed(String var1) {
- Object[] var2 = super.listenerList.getListenerList();
- ActionEvent var3 = null;
-
- for(int var4 = var2.length - 2; var4 >= 0; var4 -= 2) {
- if (var2[var4] == (class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")))) {
- if (var3 == null) {
- var3 = new ActionEvent(this, 1001, var1);
- }
-
- ((ActionListener)var2[var4 + 1]).actionPerformed(var3);
- }
- }
-
- }
-
- public FileFilter getAcceptAllFileFilter() {
- FileFilter var1 = null;
- if (this.getUI() != null) {
- var1 = this.getUI().getAcceptAllFileFilter(this);
- }
-
- return var1;
- }
-
- public AccessibleContext getAccessibleContext() {
- if (this.accessibleContext == null) {
- this.accessibleContext = new AccessibleJFileChooser(this);
- }
-
- return this.accessibleContext;
- }
-
- public JComponent getAccessory() {
- return this.accessory;
- }
-
- public int getApproveButtonMnemonic() {
- return this.approveButtonMnemonic;
- }
-
- public String getApproveButtonText() {
- return this.approveButtonText;
- }
-
- public String getApproveButtonToolTipText() {
- return this.approveButtonToolTipText;
- }
-
- public FileFilter[] getChoosableFileFilters() {
- FileFilter[] var1 = new FileFilter[this.filters.size()];
- this.filters.copyInto(var1);
- return var1;
- }
-
- public File getCurrentDirectory() {
- return this.currentDirectory;
- }
-
- public String getDescription(File var1) {
- String var2 = null;
- if (this.getFileView() != null) {
- var2 = this.getFileView().getDescription(var1);
- }
-
- if (var2 == null && this.uiFileView != null) {
- var2 = this.uiFileView.getDescription(var1);
- }
-
- return var2;
- }
-
- public String getDialogTitle() {
- return this.dialogTitle;
- }
-
- public int getDialogType() {
- return this.dialogType;
- }
-
- public FileFilter getFileFilter() {
- return this.fileFilter;
- }
-
- public int getFileSelectionMode() {
- return this.fileSelectionMode;
- }
-
- public FileSystemView getFileSystemView() {
- return this.fileSystemView;
- }
-
- public FileView getFileView() {
- return this.fileView;
- }
-
- public Icon getIcon(File var1) {
- Icon var2 = null;
- if (this.getFileView() != null) {
- var2 = this.getFileView().getIcon(var1);
- }
-
- if (var2 == null && this.uiFileView != null) {
- var2 = this.uiFileView.getIcon(var1);
- }
-
- return var2;
- }
-
- public String getName(File var1) {
- String var2 = null;
- if (this.getFileView() != null) {
- var2 = this.getFileView().getName(var1);
- }
-
- if (var2 == null && this.uiFileView != null) {
- var2 = this.uiFileView.getName(var1);
- }
-
- return var2;
- }
-
- public File getSelectedFile() {
- return this.selectedFile;
- }
-
- public File[] getSelectedFiles() {
- return this.selectedFiles == null ? new File[0] : (File[])this.selectedFiles.clone();
- }
-
- public String getTypeDescription(File var1) {
- String var2 = null;
- if (this.getFileView() != null) {
- var2 = this.getFileView().getTypeDescription(var1);
- }
-
- if (var2 == null && this.uiFileView != null) {
- var2 = this.uiFileView.getTypeDescription(var1);
- }
-
- return var2;
- }
-
- public FileChooserUI getUI() {
- return (FileChooserUI)super.ui;
- }
-
- public String getUIClassID() {
- return "FileChooserUI";
- }
-
- private boolean isAcceptAllFileFilterUsed() {
- return this.useAcceptAllFileFilter;
- }
-
- public boolean isDirectorySelectionEnabled() {
- return this.fileSelectionMode == 1 || this.fileSelectionMode == 2;
- }
-
- public boolean isFileHidingEnabled() {
- return this.useFileHiding;
- }
-
- public boolean isFileSelectionEnabled() {
- return this.fileSelectionMode == 0 || this.fileSelectionMode == 2;
- }
-
- public boolean isMultiSelectionEnabled() {
- return this.multiSelectionEnabled;
- }
-
- public boolean isTraversable(File var1) {
- Boolean var2 = null;
- if (this.getFileView() != null) {
- var2 = this.getFileView().isTraversable(var1);
- }
-
- if (var2 == null && this.uiFileView != null) {
- var2 = this.uiFileView.isTraversable(var1);
- }
-
- if (var2 == null && var1 != null) {
- if (var1.isDirectory()) {
- var2 = Boolean.TRUE;
- } else {
- var2 = Boolean.FALSE;
- }
- } else if (var2 == null) {
- return false;
- }
-
- return var2;
- }
-
- protected String paramString() {
- String var1 = this.approveButtonText != null ? this.approveButtonText : "";
- String var2 = this.dialogTitle != null ? this.dialogTitle : "";
- String var3;
- if (this.dialogType == 0) {
- var3 = "OPEN_DIALOG";
- } else if (this.dialogType == 1) {
- var3 = "SAVE_DIALOG";
- } else if (this.dialogType == 2) {
- var3 = "CUSTOM_DIALOG";
- } else {
- var3 = "";
- }
-
- String var4;
- if (this.returnValue == 1) {
- var4 = "CANCEL_OPTION";
- } else if (this.returnValue == 0) {
- var4 = "APPROVE_OPTION";
- } else if (this.returnValue == -1) {
- var4 = "ERROR_OPTION";
- } else {
- var4 = "";
- }
-
- String var5 = this.useFileHiding ? "true" : "false";
- String var6;
- if (this.fileSelectionMode == 0) {
- var6 = "FILES_ONLY";
- } else if (this.fileSelectionMode == 1) {
- var6 = "DIRECTORIES_ONLY";
- } else if (this.fileSelectionMode == 2) {
- var6 = "FILES_AND_DIRECTORIES";
- } else {
- var6 = "";
- }
-
- String var7 = this.currentDirectory != null ? this.currentDirectory.toString() : "";
- String var8 = this.selectedFile != null ? this.selectedFile.toString() : "";
- return super.paramString() + ",approveButtonText=" + var1 + ",currentDirectory=" + var7 + ",dialogTitle=" + var2 + ",dialogType=" + var3 + ",fileSelectionMode=" + var6 + ",returnValue=" + var4 + ",selectedFile=" + var8 + ",useFileHiding=" + var5;
- }
-
- public void removeActionListener(ActionListener var1) {
- super.listenerList.remove(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")), var1);
- }
-
- public boolean removeChoosableFileFilter(FileFilter var1) {
- if (this.filters.contains(var1)) {
- if (this.getFileFilter() == var1) {
- this.setFileFilter((FileFilter)null);
- }
-
- FileFilter[] var2 = this.getChoosableFileFilters();
- this.filters.removeElement(var1);
- ((JComponent)this).firePropertyChange("ChoosableFileFilterChangedProperty", var2, this.getChoosableFileFilters());
- return true;
- } else {
- return false;
- }
- }
-
- public void rescanCurrentDirectory() {
- this.getUI().rescanCurrentDirectory(this);
- }
-
- public void resetChoosableFileFilters() {
- FileFilter[] var1 = this.getChoosableFileFilters();
- this.setFileFilter((FileFilter)null);
- this.filters.removeAllElements();
- if (this.isAcceptAllFileFilterUsed()) {
- this.addChoosableFileFilter(this.getAcceptAllFileFilter());
- }
-
- ((JComponent)this).firePropertyChange("ChoosableFileFilterChangedProperty", var1, this.getChoosableFileFilters());
- }
-
- private void setAcceptAllFileFilterUsed(boolean var1) {
- boolean var2 = this.useAcceptAllFileFilter;
- this.useAcceptAllFileFilter = var1;
- if (!var1) {
- this.removeChoosableFileFilter(this.getAcceptAllFileFilter());
- } else {
- this.removeChoosableFileFilter(this.getAcceptAllFileFilter());
- this.addChoosableFileFilter(this.getAcceptAllFileFilter());
- }
-
- ((JComponent)this).firePropertyChange("AcceptAllFileFilterUsedChanged", var2, this.useAcceptAllFileFilter);
- }
-
- public void setAccessory(JComponent var1) {
- JComponent var2 = this.accessory;
- this.accessory = var1;
- ((JComponent)this).firePropertyChange("AccessoryChangedProperty", var2, this.accessory);
- }
-
- public void setApproveButtonMnemonic(char var1) {
- int var2 = var1;
- if (var1 >= 'a' && var1 <= 'z') {
- var2 = var1 - 32;
- }
-
- this.setApproveButtonMnemonic(var2);
- }
-
- public void setApproveButtonMnemonic(int var1) {
- if (this.approveButtonMnemonic != var1) {
- int var2 = this.approveButtonMnemonic;
- this.approveButtonMnemonic = var1;
- ((JComponent)this).firePropertyChange("ApproveButtonMnemonicChangedProperty", var2, this.approveButtonMnemonic);
- }
- }
-
- public void setApproveButtonText(String var1) {
- if (this.approveButtonText != var1) {
- String var2 = this.approveButtonText;
- this.approveButtonText = var1;
- ((JComponent)this).firePropertyChange("ApproveButtonTextChangedProperty", var2, var1);
- }
- }
-
- public void setApproveButtonToolTipText(String var1) {
- if (this.approveButtonToolTipText != var1) {
- String var2 = this.approveButtonToolTipText;
- this.approveButtonToolTipText = var1;
- this.setDialogType(2);
- ((JComponent)this).firePropertyChange("ApproveButtonToolTipTextChangedProperty", var2, this.approveButtonToolTipText);
- }
- }
-
- public void setCurrentDirectory(File var1) {
- File var2 = this.currentDirectory;
- if (var1 == null) {
- this.currentDirectory = this.getFileSystemView().getHomeDirectory();
- ((JComponent)this).firePropertyChange("directoryChanged", var2, this.currentDirectory);
- } else if (this.currentDirectory == null || !this.currentDirectory.equals(var1)) {
- for(File var3 = null; !this.isTraversable(var1) && var3 != var1 && !this.getFileSystemView().isRoot(var1); var1 = this.getFileSystemView().getParentDirectory(var1)) {
- var3 = var1;
- }
-
- this.currentDirectory = var1;
- ((JComponent)this).firePropertyChange("directoryChanged", var2, this.currentDirectory);
- }
- }
-
- public void setDialogTitle(String var1) {
- String var2 = this.dialogTitle;
- this.dialogTitle = var1;
- if (this.dialog != null) {
- this.dialog.setTitle(var1);
- }
-
- ((JComponent)this).firePropertyChange("DialogTitleChangedProperty", var2, var1);
- }
-
- public void setDialogType(int var1) {
- if (this.dialogType != var1) {
- if (var1 != 0 && var1 != 1 && var1 != 2) {
- throw new IllegalArgumentException("Incorrect Dialog Type: " + var1);
- } else {
- int var2 = this.dialogType;
- this.dialogType = var1;
- if (var1 == 0 || var1 == 1) {
- this.setApproveButtonText((String)null);
- }
-
- ((JComponent)this).firePropertyChange("DialogTypeChangedProperty", var2, var1);
- }
- }
- }
-
- public void setFileFilter(FileFilter var1) {
- FileFilter var2 = this.fileFilter;
- this.fileFilter = var1;
- if (this.selectedFile != null && this.fileFilter != null && !var1.accept(this.selectedFile)) {
- this.setSelectedFile((File)null);
- }
-
- ((JComponent)this).firePropertyChange("fileFilterChanged", var2, this.fileFilter);
- }
-
- public void setFileHidingEnabled(boolean var1) {
- boolean var2 = this.useFileHiding;
- this.useFileHiding = var1;
- ((JComponent)this).firePropertyChange("FileHidingChanged", var2, this.useFileHiding);
- }
-
- public void setFileSelectionMode(int var1) {
- if (this.fileSelectionMode != var1) {
- int var2 = this.fileSelectionMode;
- this.fileSelectionMode = var1;
- ((JComponent)this).firePropertyChange("fileSelectionChanged", var2, this.fileSelectionMode);
- }
- }
-
- public void setFileSystemView(FileSystemView var1) {
- FileSystemView var2 = this.fileSystemView;
- this.fileSystemView = var1;
- ((JComponent)this).firePropertyChange("FileSystemViewChanged", var2, this.fileSystemView);
- }
-
- public void setFileView(FileView var1) {
- FileView var2 = this.fileView;
- this.fileView = var1;
- ((JComponent)this).firePropertyChange("fileViewChanged", var2, var1);
- }
-
- public void setMultiSelectionEnabled(boolean var1) {
- if (this.multiSelectionEnabled != var1) {
- boolean var2 = this.multiSelectionEnabled;
- this.multiSelectionEnabled = var1;
- ((JComponent)this).firePropertyChange("fileFilterChanged", var2, this.multiSelectionEnabled);
- }
- }
-
- public void setSelectedFile(File var1) {
- File var2 = this.selectedFile;
- this.selectedFile = var1;
- if (this.selectedFile != null) {
- String var3 = this.selectedFile.getParent();
- if (var3 != null) {
- File var4 = this.getFileSystemView().createFileObject(var3);
- if (!var4.equals(this.getCurrentDirectory())) {
- this.setCurrentDirectory(var4);
- }
- }
-
- this.ensureFileIsVisible(this.selectedFile);
- }
-
- ((JComponent)this).firePropertyChange("SelectedFileChangedProperty", var2, this.selectedFile);
- }
-
- public void setSelectedFiles(File[] var1) {
- File[] var2 = this.selectedFiles;
- this.selectedFiles = var1;
- ((JComponent)this).firePropertyChange("SelectedFilesChangedProperty", var2, this.selectedFiles);
- }
-
- protected void setup(FileSystemView var1) {
- if (var1 == null) {
- var1 = FileSystemView.getFileSystemView();
- }
-
- this.setFileSystemView(var1);
- this.updateUI();
- if (this.isAcceptAllFileFilterUsed()) {
- this.setFileFilter(this.getAcceptAllFileFilter());
- }
-
- }
-
- public int showDialog(Component var1, String var2) {
- if (var2 != null) {
- this.setApproveButtonText(var2);
- this.setDialogType(2);
- }
-
- Frame var3 = var1 instanceof Frame ? (Frame)var1 : (Frame)SwingUtilities.getAncestorOfClass(class$java$awt$Frame != null ? class$java$awt$Frame : (class$java$awt$Frame = class$("java.awt.Frame")), var1);
- Object var4 = null;
- String var6;
- if (this.getDialogTitle() != null) {
- var6 = this.dialogTitle;
- } else {
- var6 = this.getUI().getDialogTitle(this);
- }
-
- this.dialog = new JDialog(var3, var6, true);
- Container var5 = this.dialog.getContentPane();
- var5.setLayout(new BorderLayout());
- var5.add(this, "Center");
- this.dialog.pack();
- this.dialog.setLocationRelativeTo(var1);
- this.dialog.show();
- return this.returnValue;
- }
-
- public int showOpenDialog(Component var1) {
- this.setDialogType(0);
- return this.showDialog(var1, (String)null);
- }
-
- public int showSaveDialog(Component var1) {
- this.setDialogType(1);
- return this.showDialog(var1, (String)null);
- }
-
- public void updateUI() {
- FileChooserUI var1 = (FileChooserUI)UIManager.getUI(this);
- ((JComponent)this).setUI(var1);
- this.uiFileView = this.getUI().getFileView(this);
- if (this.isAcceptAllFileFilterUsed()) {
- this.addChoosableFileFilter(this.getAcceptAllFileFilter());
- }
-
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- if (super.ui != null && this.getUIClassID().equals("FileChooserUI")) {
- super.ui.installUI(this);
- }
-
- }
- }
-